package com.wyx;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PlaceholderMatcher {
    public static void main(String[] args) {
        String template = "use {{#1}} template download latest  {{#2}} order";
        Pattern pattern = Pattern.compile("\\{\\{#(\\d+)}}");
        Matcher matcher = pattern.matcher(template);
        while (matcher.find()) {
            // 获取整个匹配的字符串
            String match = matcher.group(0);
            System.out.println(match);
            // 获取捕获组中的数字
            int number = Integer.parseInt(matcher.group(1));
            System.out.println("Found placeholder: " + match + " with number: " + number);
        }
    }
}
